package com.zzzy.config;

/**
 * @Author John Yan
 * @Date 2019-01-10
 * @Description 动态数据源ContextHolder
 *
 */
public class DynamicDataSourceContextHolder {
    private static final ThreadLocal<String> contextHolder = new ThreadLocal<String>();

    /**
     * @Description: 设置数据源
     * @param dataSource
     * 数据库类型
     * @return void
     * @throws
     */
    public static void setDataSource(String dataSource) {
        contextHolder.set(dataSource);
    }

    /**
     * @Description: 获取数据源
     * @param
     * @return String
     * @throws
     */
    public static String getDataSource() {
        return contextHolder.get();
    }

    /**
     * @Description: 清除数据源
     * @param
     * @return void
     * @throws
     */
    public static void clearDataSource() {
        contextHolder.remove();
    }


}
